#include "../kore2.h"

kore::ui::Window::Window(int width, int height, int left, int top, string title)
{
	this->title = title;
	this->width = width;
	this->height = height;
	this->left = left;
	this->top = top;
}

int kore::ui::Window::hittest(int x, int y)
{

}

kore::ui::Surface* kore::ui::Window::draw()
{
	kore::ui::Surface* ms = new kore::ui::Surface(this->width, this->height);

	// Draw self, then draw children
	SDL_Color bgcolor = { 100, 100, 150, 255 };
	ms->drawFillRect(0,0,this->width,this->height,bgcolor);
	// Sprites accessed from the resource "ui:window"
	kore::ResourceFile* windowres = kore::ResourceManager::instance()->getResourceFile("ui:window");

	// Now children
	map<string,ElementBase*>::iterator it;
	for (it = this->children.begin(); it != this->children.end(); it++)
	{
		kore::ui::Surface* cs = it->second->draw();
		ms->drawSurface(it->second->left, it->second->top, cs);
		delete cs;
	}

	return ms;
}
